<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">
   
   
    <body>
        <ui:composition template="../templates/splash/template.xhtml">
            <ui:define name="top"> 
                <div class="logo">
                     <h3><h:outputText value="#{msgs.mainTitle}"/></h3>
                </div>
                
                <div class="login">
                        <h:form>
                            <table>
                                <tr>
                                    <td><h:outputText value="#{msgs.email}" /></td>
                                    <td><h:inputText id="email" value="#{loginBean.email}" 
                                                     required="true"
                                                     requiredMessage="#{msgs.nameRequired}"
                                                     validatorMessage="#{msgs.invalidEmail}">
                                            <f:validateRegex pattern="#{validation.email}"/>
                                        </h:inputText>
                                        <div style="float: left">
                                            <h:message for="email" styleClass="errorMessage"/>
                                        </div>   
                                    </td>

                                    <td><h:outputText value="#{msgs.password}" /></td>
                                    <td><h:inputSecret id="password"  value="#{loginBean.password}"
                                                       required="true"
                                                       requiredMessage="#{msgs.passwordRequired}"/>
                                    <div>
                                        <h:message for="password" styleClass="errorMessage"/>
                                    </div>   
                                    </td>
                                    <td> </td>
                                    <td><h:commandButton value="#{msgs.loginAction}" action="#{loginBean.checkValidUser}"/>
                                    </td>

                                </tr>                
                            </table>

                            <div>
                                <h:outputText value="#{msgs.invalidUser}" rendered="#{loginBean.invalidUser}"/>
                            </div>    
                        </h:form>
                </div>
                <div style="clear: both"></div>
            </ui:define>



            <ui:define name="content">
                <div class="reg_box" style="float:right; margin:20px 0px 0px 0px;">
                    <h:form>
                        <h1><h:outputText value="Registration"/></h1>
                        <div class="reg_err_msg">
                            <ul>
                                <li><h:message for="name" styleClass="errorMessage"/></li>
                                <li><h:message for="lastName" styleClass="errorMessage"/></li>
                                <li><h:message for="email" styleClass="errorMessage"/></li>
                                <li><h:message for="password" styleClass="errorMessage"/></li>
                                <li><h:message for="gender" styleClass="errorMessage"/></li>
                            </ul>
                        </div>
                              <table> 
                            <tr> 
                                <td class="reg_left_col">  
                                    <h:outputLabel value="Name:" for="name" />
                                </td>
                                <td class="reg_right_col">
                                    <h:inputText id="name" value="#{registerUserBean.user.name}" title="Name"
                                                 required ="true"
                                                 requiredMessage="#{msgs.nameRequired}"/>
                                </td>
                            </tr>
                            <tr> 
                                <td class="reg_left_col">  
                                    <h:outputLabel value="LastName:" for="lastName" />
                                </td>
                                <td class="reg_right_col">
                                    <h:inputText id="lastName" value="#{registerUserBean.user.lastName}" title="LastName" 
                                                 required ="true"
                                                 requiredMessage="#{msgs.lastNameRequired}"/>
                                </td>
                            </tr>
                            <tr> 
                                <td class="reg_left_col">  
                                    <h:outputLabel value="Email:" for="email" />
                                </td>
                                <td class="reg_right_col">
                                   <h:inputText id="email" value="#{registerUserBean.user.email}" title="Email" 
                                                 required ="true"
                                                 requiredMessage="#{msgs.emailRequired}"/>
                                </td>
                            </tr>
                            <tr> 
                                <td class="reg_left_col">  
                                    <h:outputLabel value="Password:" for="password" />
                                </td>
                                <td class="reg_right_col">
                                    <h:inputSecret id="password" value="#{registerUserBean.user.password}" title="Password" 
                                                   required ="true"
                                                 requiredMessage="#{msgs.passwordRequired}"/>
                                </td>
                            </tr>
                            <tr> 
                                <td class="reg_left_col">  
                                   <h:outputText value="Gender:" />
                                </td>
                                <td class="reg_right_col">
                                      <h:selectOneRadio value="#{registerUserBean.user.gender}"
                                              id="gender"
                                              required ="true"
                                              requiredMessage="#{msgs.genderRequired}"
                                              >
                                             <f:selectItem itemValue="f" itemLabel="female" />
                                             <f:selectItem itemValue="m" itemLabel="male" />
                                      </h:selectOneRadio>
                                </td>
                            </tr>
                            <!--<tr> 
                                <td class="reg_left_col">  
                                    <h:outputLabel value="Date of birth:" for="dateOfBirth" />
                                </td>
                                <td class="reg_right_col">
                                     <h:selectOneMenu value="#{registerUserBean.dateOfBirth.selectedMonth}">
                                        <f:selectItem itemValue="none" itemLabel="Month" />  
                                        <f:selectItems value="#{registerUserBean.dateOfBirth.months}" var="month"/>
                                     </h:selectOneMenu>  

                                     <h:selectOneMenu id="days" value="#{registerUserBean.dateOfBirth.selectedDay}">
                                         <f:selectItem itemValue="#{null}" itemLabel="Day" />
                                         <f:selectItems value="#{registerUserBean.dateOfBirth.days}" var="day"/>
                                    </h:selectOneMenu> 

                                    <h:selectOneMenu id="years" value="#{registerUserBean.dateOfBirth.selectedYear}">
                                         <f:selectItem itemValue="#{null}" itemLabel="Year" />
                                         <f:selectItems value="#{registerUserBean.dateOfBirth.years}"/>
                                    </h:selectOneMenu> 
                                </td>
                            </tr>-->
                            <tr>
                                <td class="reg_left_col"></td>
                                <td class="reg_right_col">   <h:commandButton value="Submit" action="#{registerUserBean.registerUser()}"/></td>
                            </tr>
                        </table>
                    </h:form>
                    <div>
                        <h:outputText value="#{msgs.errorCreatingUser}" rendered="#{registerUserBean.errorCreatingUser}"/>
                    </div>    
                </div>

                <div style="clear:both"></div>
            </ui:define>
        </ui:composition>
    </body>
</html>